using FluentNHibernate.Mapping;
using Nb.Tenants.Libs.Domains.Models;

namespace Nb.Tenants.Libs.Infrastructures
{
    public abstract class BaseTenantEntityMap<T> : ClassMap<T> where T : MultiTenantNbEntity<T>
    {
        protected BaseTenantEntityMap()
        {
            Component(x => x.TenantId, s => s.Map(o => o.Id).Column("TenantId"));
        }
    }

    public class RoleMap : BaseTenantEntityMap<Role>
    {
        public RoleMap()
        {
            Table("Lib_Tenants_Role");
            Id(x => x.Id).GeneratedBy.GuidComb();

            Map(x => x.Name);
        }
    }

    public class UserMap : ClassMap<User>
    {
        public UserMap()
        {
            Table("Lib_Tenants_User");
            Id(x => x.Id).GeneratedBy.GuidComb();

            Component(x => x.TenantId, s => s.Map(o => o.Id).Column("TenantId"));

            Map(x => x.LoginName);
        }
    }
}